package com.liuya.safe.model;

import com.liuya.base.BaseModel;

import java.io.Serializable;

public class SafePrivilege extends BaseModel implements Serializable {
    public static final String TREE_ROOT_NAME = "root";
    public static final String BUSINESS_PRIVILEGE_TREE_ROOT_ID = "0";
    public static final String NON_ROLE_PRIVILEGE_TREE_ROOT_ID = "-1";
    public static final String NULL_ROOT_ID = "-2";
    public static final String AUTH_ADMIN_ID = "-3";
    public static final String POLICY_ADMIN_ID = "-4";
    public static final String ASSIGN_ROLE_TO_USER_ID = "-5";
    public static final String ROLE_ADMIN_ID = "-6";
    public static final int BUSINESS_PRIVILEGE = 0;
    public static final int NON_ROLE_PRIVILEGE = 1;
    public static final int DECISION_FIRST_APPLICABLE = 0;
    public static final int DECISION_ORDERED_PERMIT_OVERRIDES = 1;
    public static final int DECISION_ORDERED_DENY_OVERRIDES = 2;
    public static final int QUERY_FIRST_APPLICABLE = 0;

    private Integer decisionPolicyCombAlg;
    private Integer queryPolicyCombAlg;
    private Integer type;
    private String constantName;
    private String url;
    private String target;
    private Integer orderNum;
    private Boolean display;
    private Integer status;

    public Integer getDecisionPolicyCombAlg() {
        return decisionPolicyCombAlg;
    }

    public void setDecisionPolicyCombAlg(Integer decisionPolicyCombAlg) {
        this.decisionPolicyCombAlg = decisionPolicyCombAlg;
    }

    public Integer getQueryPolicyCombAlg() {
        return queryPolicyCombAlg;
    }

    public void setQueryPolicyCombAlg(Integer queryPolicyCombAlg) {
        this.queryPolicyCombAlg = queryPolicyCombAlg;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getConstantName() {
        return constantName;
    }

    public void setConstantName(String constantName) {
        this.constantName = constantName == null ? null : constantName.trim();
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null ? null : url.trim();
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target == null ? null : target.trim();
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public Boolean getDisplay() {
        return display;
    }

    public void setDisplay(Boolean display) {
        this.display = display;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public boolean equals(Object o) {
        if (o instanceof SafePrivilege) {
            SafePrivilege privilege = (SafePrivilege) o;
            return (privilege.getId() == this.getId() && privilege.getName().equals(this.getName()) && privilege.type == this.type);
        }
        return false;
    }

    public Object clone() {
        SafePrivilege newOne = new SafePrivilege();
        newOne.setConstantName(constantName);
        newOne.setDecisionPolicyCombAlg(decisionPolicyCombAlg);
        newOne.setDescription(getDescription());
        newOne.setId(getId());
        newOne.setIsLeaf(getIsLeaf());
        newOne.setName(getName());
        newOne.setPid(getPid());
        newOne.setQueryPolicyCombAlg(queryPolicyCombAlg);
        newOne.setTarget(target);
        newOne.setType(type);
        newOne.setUrl(url);
        newOne.setOrderNum(orderNum);

        return newOne;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(getId());
        sb.append(", pid=").append(getPid());
        sb.append(", description=").append(getDescription());
        sb.append(", name=").append(getName());
        sb.append(", isLeaf=").append(getIsLeaf());
        sb.append(", decisionPolicyCombAlg=").append(decisionPolicyCombAlg);
        sb.append(", queryPolicyCombAlg=").append(queryPolicyCombAlg);
        sb.append(", type=").append(type);
        sb.append(", constantName=").append(constantName);
        sb.append(", url=").append(url);
        sb.append(", target=").append(target);
        sb.append(", orderNum=").append(orderNum);
        sb.append(", display=").append(display);
        sb.append(", status=").append(status);
        sb.append("]");
        return sb.toString();
    }
//
//    @Override
//    public boolean equals(Object that) {
//        if (this == that) {
//            return true;
//        }
//        if (that == null) {
//            return false;
//        }
//        if (getClass() != that.getClass()) {
//            return false;
//        }
//        SafePrivilege other = (SafePrivilege) that;
//        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
//            && (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid()))
//            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
//            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
//            && (this.getIsLeaf() == null ? other.getIsLeaf() == null : this.getIsLeaf().equals(other.getIsLeaf()))
//            && (this.getDecisionPolicyCombAlg() == null ? other.getDecisionPolicyCombAlg() == null : this.getDecisionPolicyCombAlg().equals(other.getDecisionPolicyCombAlg()))
//            && (this.getQueryPolicyCombAlg() == null ? other.getQueryPolicyCombAlg() == null : this.getQueryPolicyCombAlg().equals(other.getQueryPolicyCombAlg()))
//            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
//            && (this.getConstantName() == null ? other.getConstantName() == null : this.getConstantName().equals(other.getConstantName()))
//            && (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
//            && (this.getTarget() == null ? other.getTarget() == null : this.getTarget().equals(other.getTarget()))
//            && (this.getOrderNum() == null ? other.getOrderNum() == null : this.getOrderNum().equals(other.getOrderNum()))
//            && (this.getDisplay() == null ? other.getDisplay() == null : this.getDisplay().equals(other.getDisplay()))
//            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
//    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getIsLeaf() == null) ? 0 : getIsLeaf().hashCode());
        result = prime * result + ((getDecisionPolicyCombAlg() == null) ? 0 : getDecisionPolicyCombAlg().hashCode());
        result = prime * result + ((getQueryPolicyCombAlg() == null) ? 0 : getQueryPolicyCombAlg().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getConstantName() == null) ? 0 : getConstantName().hashCode());
        result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
        result = prime * result + ((getTarget() == null) ? 0 : getTarget().hashCode());
        result = prime * result + ((getOrderNum() == null) ? 0 : getOrderNum().hashCode());
        result = prime * result + ((getDisplay() == null) ? 0 : getDisplay().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        return result;
    }
}